# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgbase=python-ipaddr
pkgname=('python2-ipaddr' 'python-ipaddr')
_pkgname=ipaddr
pkgver=2.2.0
pkgrel=9
pkgdesc='An IPv4/IPv6 manipulation library in Python.'
arch=('any')
url='https://pypi.org/project/ipaddr/#files'
license=('APACHE')
makedepends=('python2-setuptools' 'python-setuptools')
source=("https://files.pythonhosted.org/packages/source/${_pkgname::1}/$_pkgname/$_pkgname-$pkgver.tar.gz")
sha512sums=('5adb117c44e6e5dbdb9e96543aa7a34f35b4a4ec9baa163a25448058c34091bf4019d24f0250928291e4d4bc97dcdf75865daef739e2d94f98cc584e6e6c50dd')

prepare() {
  cp -a "$_pkgname-$pkgver"{,-2}

  sed -e 's|/usr/bin/python|/usr/bin/python2|' -i \
    "$_pkgname-$pkgver-2/ipaddr.py"
}

build() {
  cd "$_pkgname-$pkgver-2"

  python2 setup.py build

  cd "$srcdir/$_pkgname-$pkgver"

  python setup.py build
}

package_python2-ipaddr() {
  depends=('python2')

  cd "$_pkgname-$pkgver-2"

  python2 setup.py install --root="$pkgdir" --optimize=1 --skip-build
}

package_python-ipaddr() {
  depends=('python')

  cd "$_pkgname-$pkgver"

  python setup.py install --root="$pkgdir" --optimize=1 --skip-build
}

